package com.itheima.exception;


import com.itheima.jsonresult.JsonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice  //用于标识当前类为REST风格对应的异常处理器
public class ProjectExceptionAdvice {
    //统一处理所有的Exception异常
    @ExceptionHandler(loginException.class)
    public JsonResult loginException(Exception ex){
        return new JsonResult(0,"账号密码错误",null,null);
    }

    @ExceptionHandler(updateException.class)
    public JsonResult updateException(Exception ex){
        return new JsonResult(0,"修改失败",null,null);
    }

    @ExceptionHandler(tokenException.class)
    public JsonResult tokenException(Exception ex){
        return new JsonResult(0,"token不存在或已过期",null,null);
    }

    @ExceptionHandler(checkException.class)
    public JsonResult checkException(Exception ex){
        return new JsonResult(0,"校验失败",null,null);
    }
}
